package org.example.supplychain.controller;

import org.example.supplychain.domain.Material;
import org.example.supplychain.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/material")
public class MaterialController {
    @Autowired
    private MaterialService materialService;

    @RequestMapping("/delete/{materialId}")
    public void deleteMaterialByMaterialID(@PathVariable long materialId) {
        materialService.deleteMaterialByMaterialId(materialId);
    }

//    @RequestMapping("/update/{materialId}")
//    public void updateMaterial(@PathVariable long materialId, @RequestParam("materialName") String materialName, @RequestParam("materialNumber") long materialNumber, @RequestParam("price") double price, @RequestParam("inventoryId") long inventoryId, @RequestParam("supplierId") long supplierId) {
//        Material material = new Material();
//        material.setMaterialId(materialId);
//        material.setMaterialName(materialName);
//        material.setMaterialNumber(materialNumber);
//        material.setPrice(price);
//        material.setInventoryId(inventoryId);
//        material.setSupplierId(supplierId);
//        materialService.updateMaterial(materialId);
//    }
//
//    @RequestMapping("/create")
//    public void addMaterial(@RequestParam("materialName") String materialName, @RequestParam("materialNumber") long materialNumber, @RequestParam("price") double price, @RequestParam("inventoryId") long inventoryId, @RequestParam("supplierId") long supplierId) {
//        Material material = new Material();
//        material.setMaterialName(materialName);
//        material.setMaterialNumber(materialNumber);
//        material.setPrice(price);
//        material.setInventoryId(inventoryId);
//        material.setSupplierId(supplierId);
//        materialService.addMaterial(material);
//    }

    @RequestMapping("/detail/{materialId}")
    public Material getMaterialByMaterialID(@PathVariable long materialId) {
        return materialService.getMaterialByMaterialID(materialId);
    }
}
